//
//  JStudCell.m
//  ZHZtest
//
//  Created by 李彦宏 on 2018/1/16.
//  Copyright © 2018年 LYH. All rights reserved.
//

#import "JStudCell.h"
@interface JStudCell()


@end
@implementation JStudCell

//类方法快速创建cell
+(instancetype)cellwithTableview:(UITableView *)tableview{
    
    // 1.创建cell
    static NSString *ID = @"cell223";
    JStudCell *cell = [tableview dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[JStudCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
    }
    return  cell;
}
/**
 *  cell的初始化方法，一个cell只会调用一次
 *  一般在这里添加所有可能显示的子控件，以及子控件的一次性设置
 */
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        //添加UI控件
        [self setUI];
    }
    return self;
}

-(void)setUI{
    UILabel *lb1=[[UILabel alloc]init];
//    lb1.text=@"张三";
    lb1.textColor=[UIColor blackColor];
    lb1.textAlignment=NSTextAlignmentLeft;
    _lb1=lb1;
    [self.contentView addSubview:lb1];
    
    UILabel *lb2=[[UILabel alloc]init];
//    lb2.text=@"专业XXXXXX";
    lb2.textColor=[UIColor blackColor];
    lb2.textAlignment=NSTextAlignmentCenter;
    lb2.numberOfLines=0;
    lb2.font=[UIFont systemFontOfSize:14];
    _lb2=lb2;
    [self.contentView addSubview:lb2];
    UILabel *lb3=[[UILabel alloc]init];
    lb3.text=@"姓名:";
    lb3.textColor=[UIColor blackColor];
    lb3.textAlignment=NSTextAlignmentLeft;
    [self.contentView addSubview:lb3];
    
    UILabel *lb4=[[UILabel alloc]init];
    lb4.text=@"专业:";
    lb4.textColor=[UIColor blackColor];
    lb4.textAlignment=NSTextAlignmentLeft;
    [self.contentView addSubview:lb4];
    
    UILabel *lb5=[[UILabel alloc]init];
    lb5.text=@">";
    lb5.font=[UIFont systemFontOfSize:15];
    lb5.textColor=[UIColor lightGrayColor];
    lb5.textAlignment=NSTextAlignmentCenter;
    [self.contentView addSubview:lb5];
    
    [lb3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(10);
        make.size.mas_equalTo(CGSizeMake(45, 30));
        make.top.equalTo(self.contentView.mas_top).offset(7);
    }];
    [lb1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(lb3.mas_right).offset(10);
        make.width.mas_equalTo(75);
        make.centerY.equalTo(lb3);
    }];
    
    [lb4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(50);
        make.centerY.equalTo(lb3);
        make.left.equalTo(lb1.mas_right).offset(15);
    }];
    [lb5 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(lb3);
    make.right.equalTo(self.contentView.mas_right).offset(-5);
        make.width.mas_equalTo(10);
    }];
    [lb2 mas_makeConstraints:^(MASConstraintMaker *make) {
       
    make.top.equalTo(self.contentView.mas_top).offset(0);
    make.bottom.equalTo(self.contentView.mas_bottom).offset(0);
      make.right.equalTo(lb5.mas_left).offset(-5);
        make.left.equalTo(lb4.mas_right).offset(2);
    }];
    
}

- (void)setSDmodel:(SDUserModel *)SDmodel{
    _SDmodel=SDmodel;
    _lb1.text=_SDmodel.name;
    _lb2.text=_SDmodel.goal;
    
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
